'use strict';

module.exports = {
  up: (queryInterface, Sequelize) => {
    return queryInterface.sequelize.transaction((t) => {
      return Promise.all([
          queryInterface.addColumn('Cars', 'CarFenceId', {
            type: Sequelize.INTEGER.UNSIGNED,
            references: {
              model: 'CarFences', // name of Target model
              key: 'id', // key in Target model that we're referencing
            },
            onUpdate: 'CASCADE',
            onDelete: 'SET NULL',
          }, { transaction: t }),
          queryInterface.addColumn('CorporateEntities', 'CarFenceId', {
            type: Sequelize.INTEGER.UNSIGNED,
            references: {
              model: 'CarFences', // name of Target model
              key: 'id', // key in Target model that we're referencing
            },
            onUpdate: 'CASCADE',
            onDelete: 'SET NULL',
          }, { transaction: t }),
          queryInterface.addColumn('CarFences', 'name', {
            type: Sequelize.STRING,
          }, { transaction: t }),
          queryInterface.addColumn('CarFences', 'note', {
            type: Sequelize.STRING,
          }, { transaction: t }),
         
          
      ])
    })
  },

  down: (queryInterface, Sequelize) => {
    return queryInterface.sequelize.transaction((t) => {
      return Promise.all([
          queryInterface.removeColumn('CorporateEntities', 'CarFenceId',
           { transaction: t }),
           queryInterface.removeColumn('Cars', 'CarFenceId',
           { transaction: t }),
           queryInterface.removeColumn('CarFences', 'name',
           { transaction: t }),
           queryInterface.removeColumn('CarFences', 'note',
           { transaction: t }),
      ])
    })
  }
};
